import request from '@/utils/request'

// base
const base = process.env.VUE_APP_BASE_API3 + '/schedule'
export function baseRequest(val) {
  return request({
    url: base + val.url,
    method: val.method,
    data: val.data
  })
}

// 新增
export function add(val) {
  return baseRequest({
    url: '/save',
    method: 'post',
    data: val
  })
}
// 更新
export function update(val) {
  return baseRequest({
    url: '/save',
    method: 'post',
    data: val
  })
}

// 发布
export function publish(val) {
  return baseRequest({
    url: '/doPublish',
    method: 'post',
    data: val
  })
}

// 删除
export function deleteById(val) {
  return baseRequest({
    url: '/delete',
    method: 'post',
    data: { id: val }
  })
}

// 批量删除
export function batchDelete(val) {
  return baseRequest({
    url: '/batchDelete',
    method: 'post',
    data: val
  })
}

// 查询档期
export function getPublishedList() {
  return baseRequest({
    url: '/getPublishedList',
    method: 'get',
    data: null
  })
}

// 根据档期id和采购id删除档期关联的采购
export function deleteScheduleBuyer(val) {
  return baseRequest({
    url: '/buyer/deleteByScheduleIdAndBuyerId',
    method: 'post',
    data: val
  })
}
